import { createRouter, createWebHistory } from 'vue-router'
import login from '@/views/login/Login.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: () => import('@/views/HomePage.vue'),
      redirect: '/home',
      children: [
        {
          path: '/main',
          component: () => import('@/views/Main/index.vue'),
          meta: { title: '详情' }
        },
        {
          path: '/home',
          component: () => import('@/views/home/Main.vue')
        },
        {
          path: '/user',
          component: () => import('@/views/user/user.vue'),
          redirect: '/user/personalData',
          children: [
            {
              path: 'personalData',
              component: () => import('@/views/user/personalData.vue')
            },
            {
              path: 'myMessage',
              component: () => import('@/views/user/myMessage.vue')
            },
            {
              path: 'myLike',
              component: () => import('@/views/user/myLike.vue')
            },
            {
              path: 'saveSetting',
              component: () => import('@/views/user/saveSetting.vue')
            }
          ]
        }, 
        {
          path: '/search:id',
          component: () => import('@/views/search/search.vue')
        },
        {
          path: '/message',
          component: () => import('@/views/message/message.vue')
        }
      ]
    },
    {
      path: '/login',
      component: login
    },
    {
      path: '/register',
      component: () => import('@/views/login/Register.vue')
    },
    {
      path: '/admin',
      component: () => import('@/views/admin/index.vue'),
      redirect:'/admin/aHome',
      children:[
        {
          path:'aHome',
          component:()=>import('@/views/admin/ahome.vue')
        },
        {
          path:'aMessage',
          component:()=>import('@/views/admin/message.vue')
        },
        {
          path:'sayings',
          component:()=>import('@/views/admin/sayings.vue')
        },
        {
          path:'users',
          component:()=>import('@/views/admin/users.vue')
        },
        {
          path:'urlManagement',
          component:()=>import('@/views/admin/urlManagement.vue')
        },
      ]
    },
    {
      path: '/:pathMatch(.*)*',
      component: () => import('@/views/NotFound.vue'),
    },
  ],
})

export default router
